clear			all
set 			more off
cd 				"~/Dropbox/Indonesia Migration/" // Specify your root directory here
/*******************************************************************************
							First Stage
********************************************************************************/
use				"Data/Merged", clear
set				matsize 11000
reghdfe			per_immig_cst_5Y pred_per_immig_cst_5Y_5Y ///
				av_high_educ_ct prop_male_ct av_age_ct,  ///
				a(i.year#i.geolev1 i.geolev2) cl(geolev1) 
local 			clusters = `e(N_clust)'
su				`e(depvar)' if e(sample) == 1, d				
local 			meandv = r(mean)
outreg2			using "Tables/First stage.xlsx", excel tex replace ///
				dec(2) ctitle(5Y Alpha) label keep (pred_per_immig_cst_5Y_5Y) /// 
				nocons nonotes addtext("District FE", YES, "Province-Year FE", YES, ///
				"# of districts", `clusters', "Mean of DV", `: di %9.2f `meandv'')	
				
reghdfe			per_immig_cst_5Y pred_per_immig_cst_10Y_5Y ///
				av_high_educ_ct prop_male_ct av_age_ct,  ///
				a(i.year#i.geolev1 i.geolev2) cl(geolev1) 
local 			clusters = `e(N_clust)'
su				`e(depvar)' if e(sample) == 1, d				
local 			meandv = r(mean)
outreg2			using "Tables/First stage.xlsx", excel tex append ///
				dec(2) ctitle(10Y Alpha) label keep (pred_per_immig_cst_10Y_5Y) /// 
				nocons nonotes addtext("District FE", YES, "Province-Year FE", YES, ///
				"# of districts", `clusters', "Mean of DV", `: di %9.2f `meandv'')	
				
reghdfe			per_immig_cst_5Y pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y  ///
				av_high_educ_ct prop_male_ct av_age_ct,  ///
				a(i.year#i.geolev1 i.geolev2) cl(geolev1) 
local 			clusters = `e(N_clust)'
su				`e(depvar)' if e(sample) == 1, d				
local 			meandv = r(mean)
outreg2			using "Tables/First stage.xlsx", excel tex append ///
				dec(2) ctitle(Current % Migrants) label ///
				keep (pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y ) /// 
				nocons nonotes addtext("District FE", YES, "Province-Year FE", YES, ///
				"# of districts", `clusters', "Mean of DV", `: di %9.2f `meandv'')				
				
reghdfe			per_immig_cst_5Y_lag pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y  ///
				av_high_educ_ct prop_male_ct av_age_ct,  ///
				a(i.year#i.geolev1 i.geolev2) cl(geolev1) 
local 			clusters = `e(N_clust)'
su				`e(depvar)' if e(sample) == 1, d				
local 			meandv = r(mean)
outreg2			using "Tables/First stage.xlsx", excel tex append ///
				dec(2) ctitle(Lagged % Migrants) label ///
				keep (pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y ) /// 
				nocons nonotes addtext("District FE", YES, "Province-Year FE", YES, ///
				"# of districts", `clusters', "Mean of DV", `: di %9.2f `meandv'')					
				

/*******************************************************************************
							First Stage Province level
********************************************************************************/
use				"Data/Merged province level", clear
set				matsize 11000
reghdfe			per_immig_cst_5Y pred_per_immig_cst_5Y_5Y ///
				av_high_educ_ct prop_male_ct av_age_ct,  ///
				a(i.year i.geolev1) cl(geolev1) 
su				`e(depvar)' if e(sample) == 1, d				
local 			meandv = r(mean)
outreg2			using "Tables/First stage province level.xlsx", excel tex replace ///
				dec(2) ctitle(5Y Alpha) label keep (pred_per_immig_cst_5Y_5Y) /// 
				nocons nonotes addtext("Province FE", YES, "Year FE", YES, ///
				"# of provinces", `e(N_clust)', "Mean of DV", `: di %9.2f `meandv'')	
				
reghdfe			per_immig_cst_5Y pred_per_immig_cst_10Y_5Y ///
				av_high_educ_ct prop_male_ct av_age_ct,  ///
				a(i.year i.geolev1) cl(geolev1) 
su				`e(depvar)' if e(sample) == 1, d				
local 			meandv = r(mean)
outreg2			using "Tables/First stage province level.xlsx", excel tex append ///
				dec(2) ctitle(10Y Alpha) label keep (pred_per_immig_cst_10Y_5Y) /// 
				nocons nonotes addtext("Province FE", YES, "Year FE", YES, ///
				"# of provinces", `e(N_clust)', "Mean of DV", `: di %9.2f `meandv'')	
				
reghdfe			per_immig_cst_5Y pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y  ///
				av_high_educ_ct prop_male_ct av_age_ct,  ///
				a(i.year i.geolev1) cl(geolev1) 
su				`e(depvar)' if e(sample) == 1, d				
local 			meandv = r(mean)
outreg2			using "Tables/First stage province level.xlsx", excel tex append ///
				dec(2) ctitle(Current % Migrants) label ///
				keep (pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y ) /// 
				nocons nonotes addtext("Province FE", YES, "Year FE", YES, ///
				"# of provinces", `e(N_clust)', "Mean of DV", `: di %9.2f `meandv'')	
				
reghdfe			per_immig_cst_5Y_lag pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y  ///
				av_high_educ_ct prop_male_ct av_age_ct,  ///
				a(i.year i.geolev1) cl(geolev1) 
su				`e(depvar)' if e(sample) == 1, d				
local 			meandv = r(mean)
outreg2			using "Tables/First stage province level.xlsx", excel tex append ///
				dec(2) ctitle(Lagged % Migrants) label ///
				keep (pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y ) /// 
				nocons nonotes addtext("Province FE", YES, "Year FE", YES, ///
				"# of provinces", `e(N_clust)', "Mean of DV", `: di %9.2f `meandv'')	
